import { Pipe, PipeTransform } from "@angular/core";

@Pipe({ name: "cNumber" })
export class CNumberPipe implements PipeTransform {
  transform(input: any, padding: any = " ") {
      padding = padding;
      input = String(input);
      const convertMap = [
        "零",
        "一",
        "二",
        "三",
        "四",
        "五",
        "六",
        "七",
        "八",
        "九"
      ];

      const inputList = input.split("");

      return inputList.reduce((pre, cur) => {
        return pre + (convertMap[cur] || padding);
      }, "");
  }
}
